package com.compass.doctor.ui.chat.attachment

import com.compass.doctor.R
import com.compass.framework.constant.CERTIFICATE_CODE
import com.compass.framework.model.Drug
import com.compass.framework.model.MessageBody
import com.compass.framework.utils.getStringFromResource
import com.netease.yunxin.kit.corekit.im.custom.CustomAttachment
import org.json.JSONObject

/**
 * Description： 住院证
 * Date:2024/1/22 17:18
 */
class HospitalizationCertificateAttachment : CustomAttachment(CERTIFICATE_CODE) {
    private var diagnosisName: String? = null //诊断
    private var inpatientWardName: String? = null//病区
    private var id: String? = null//住院证id



    //重写数据解析方法，这里面数据以JSONObject格式进行传输，所以您可以制定自己的数据格式。
    //这个示例表示，自定义数据格式为{"customer_message_key":"我是一个自定义消息"}
    override fun packData(): JSONObject {
        var data = JSONObject()
        data.put("diagnosisName", diagnosisName)
        data.put("inpatientWardName", inpatientWardName)
        data.put("id", id)
        return data
    }


    override fun parseData(jsonObject: JSONObject?) {
        // 从接收到的消息内容中解析您的数据
        jsonObject?.let {
            this.diagnosisName = jsonObject.getString("diagnosisName")
            this.inpatientWardName = jsonObject.getString("inpatientWardName")
            this.id = jsonObject.getString("id")
        }

    }


    /**
     * 设置问诊单数据
     */
    fun setHospitalizationData(diagnosisName: String?, inpatientWardName: String?, id:String) {
        this.diagnosisName = diagnosisName;
        this.inpatientWardName = inpatientWardName;
        this.id = id;


    }


    override fun getContent(): String {
        return getStringFromResource(R.string.attachment_hospitalization_msg)
    }


    fun getDiagnosisName(): String? {
        return diagnosisName;
    }

    fun getInpatientWardName(): String? {
        return inpatientWardName;
    }

    fun getId(): String? {
        return id;
    }


}